#ifndef NORMALMODELANGMF_H
#define NORMALMODELANGMF_H

#include <protomol/integrator/STSIntegrator.h>
#include <protomol/integrator/normal/NormalModeUtilities.h>

#include <protomol/type/Vector3DBlock.h>

namespace ProtoMol {

  class ScalarStructure;
  class ForceGroup;

  //__________________________________________________ NormalModeCompLang
  class NormalModeLangMF : public STSIntegrator, public NormalModeUtilities {
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // Constructors, destructors, assignment
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  public:
    NormalModeLangMF();
//change the constructor
    NormalModeLangMF(Real timestep, int firstmode, int nummode, Real gamma, int seed, Real temperature, bool gencn,
                            ForceGroup *overloadedForces);
    ~NormalModeLangMF(); 

  public:
    virtual std::string getIdNoAlias() const{return keyword;}
    virtual unsigned int getParameterSize() const{return 7;}  
    virtual void getParameters(std::vector<Parameter>& parameters) const;
    virtual Vector3DBlock* fastspaceForce(Vector3DBlock * force, Vector3DBlock * iPforce);

  public:
    virtual void initialize(ProtoMolApp* app);

  private:
    virtual int minimizer(Real peLim, int numloop, bool simpM, bool reDiag,
      int *forceCalc, Real *lastLambda, ScalarStructure *myEnergies,
      Vector3DBlock *myPositions, GenericTopology *myTopo);
    virtual void forceProjection();
  public: 
    virtual void run(int numTimesteps,int numFastTimesteps);

  public:
    static const std::string keyword;

  private:
    virtual STSIntegrator* doMake(const std::vector<Value>& values, ForceGroup* fg)const;

  protect:
    void doHalfKickSlow();
    void doHalfKickFast();
    void doDrift();
  private:
    bool genCompNoise;

    int aveForceCount;
    Real minLim;
    int maxMinSteps;
    Vector3DBlock slowForces;
    Vector3DBlock slowForcesAvg;
    int firstFastMode;
    int firstSlowMode;
    int numSlowMode;
    int numFastMode;
  };
}

#endif
